public class TestGeometricObject {
  /** Main method */
  public static void main(String[] args) {
    // Declare and initialize two geometric objects
    GeometricObject geoObject1 = new Circle(5);
    GeometricObject geoObject2 = new Rectangle(5, 3);
    //
    GeometricObject geometricObject4 = new Triangle(3,4,3,5,4);  //


    //  displayGeometricObject(geometricObject4);三角形
    // 打印最大和最小的两个
    equalArea(geoObject1,geoObject2,geometricObject4);
    equalArea2(geoObject1,geoObject2,geometricObject4);


  }

  /** A method for comparing the areas of two geometric objects */
  public static void equalArea(GeometricObject object1,
      GeometricObject object2,GeometricObject object3) {
    if (object1.getArea()>object2.getArea()) {
      if (object2.getArea()>object3.getArea()) {
          displayGeometricObject(object1);
      }else if (object3.getArea()>object1.getArea()){
          displayGeometricObject(object3);
      }
    }else if (object2.getArea()>object3.getArea()) {
        displayGeometricObject(object2);
    }else {
        displayGeometricObject(object3);
    }
  }

  public static void equalArea2(GeometricObject object1,
                               GeometricObject object2,GeometricObject object3) {
    if (object1.getArea()<object2.getArea()) {
      if (object2.getPerimeter()<object3.getPerimeter()) {
        displayGeometricObject(object1);
      }else if (object3.getPerimeter()<object1.getPerimeter()){
        displayGeometricObject(object3);
      }
    }else if (object2.getPerimeter()<object3.getPerimeter()) {
      displayGeometricObject(object2);
    }else {
      displayGeometricObject(object3);
    }
  }
  // 比较



  /** A method for displaying a geometric object */
  public static void displayGeometricObject(GeometricObject object) {
    System.out.println();
    System.out.println("The area is " + object.getArea());
    System.out.println("The perimeter is " + object.getPerimeter());
  }
}
